<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../assert/css/font.css" th:href="@{/assert/css/font.css}"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap.min.css" th:href="@{/assert/css/bootstrap.min.css}"/>
    <link rel="stylesheet" href="../../../assert/css/plugin/chosen/chosen.css"
          th:href="@{/assert/css/plugin/chosen/chosen.css}"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap-table.css" th:href="@{/assert/css/bootstrap-table.css}"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap-select.min.css"
          th:href="@{/assert/css/bootstrap-select.min.css}"/>
    <link href="../../../assert/css/animate.min.css" rel="stylesheet" th:href="@{/assert/css/animate.min.css}">
    <link href="../../../assert/css/plugin/toastr/toastr.min.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/toastr/toastr.min.css}">
    <link href="../../../assert/css/plugin/jsTree/themes/default/style.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/jsTree/themes/default/style.css}">
    <link href="../../../assert/css/loaders.css" rel="stylesheet"
          th:href="@{/assert/css/loaders.css}">
    <link rel="stylesheet" href="../../../assert/css/city-picker.css" th:href="@{/assert/css/city-picker.css}"/>
    <link rel="stylesheet" href="../../../assert/css/jquery-ui.css" th:href="@{/assert/css/jquery-ui.css}"/>
    <link rel="stylesheet" href="../../../assert/css/index.css" th:href="@{/assert/css/index.css(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"/>

    <style>
        .search_group label.control-label{
            width:105px;
        }
        .chartsBox{
            width:100%;
            height:543px;
        }
        .charts{
            position: absolute;
            width:100%
        }
        #mapCharts{
            z-index:1
        }
        #subCharts{
            z-index:20
        }
    </style>
</head>
<body>
<!--添加业务分类/场景模态框-->
<div class="modal fade" id="workModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="width: 1000px;">
        <div class="modal-content">
            <div>
                <div class="modal-header">
                    <button type="button" class="close closeAudioModel" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">选择业务分类/场景</h4>
                </div>
                <div class="modal-body">
                    <div class="selectModel" style="height:570px !important;">
                        <div class="menu_left">
                            <div class="search_box">
                                <input type="text" autocomplete="off"><span class="fa fa-search fa_btn"
                                                                            id="searchMenuWork"></span>
                            </div>
                            <div id="jstree" class="scrollbar" style="height:520px;">

                            </div>
                        </div>
                        <div class="model_right" style="width:480px;height: 100%;">
                            <!--                            <div class="search_box">-->
                            <!--                                <input type="text" autocomplete="off" placeholder="业务分类名称" style="width: 450px;" id="tagTreeName"><span-->
                            <!--                                    class="fa fa-search fa_btn" id="searchworkName"></span>-->
                            <!--                            </div>-->
                            <table id="workTableWin"></table>
                        </div>
                        <div class="model_right" style="width: 270px;height: 546px;">
                            <div class="tagSModel" id="workSModel">
                                <div>已选业务分类/场景：</div>
                                <ul style="overflow: auto;height: 556px;">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="saveWork">保存</button>
                    <button type="button" class="btn btn-white closeAudioModel" data-dismiss="modal" id="closeWork">关闭</button>
                </div>
            </div>
        </div>
    </div>
</div>

<a id="basePath" th:href="@{/}"></a>
<div class="wrapper wrapper-content">
    <div class="ibox">
        <!--全局功能按钮-->
        <div class="tools_bar">
            <div class="pull-left">
                <a href="#" class="btn btn-default active" id="btnSearch" title="隐藏查询条"><i class="fa fa-filter"></i> 隐藏</a>
                <a href="#" class="btn btn-default active" id="refresh"><i class="fa fa-refresh"></i> 刷新</a>
            </div>
        </div>
        <!--查询条-->
        <div class="search on">
            <div class="search_group">
                <label class="control-label"><span class="respan">*</span>日期：</label>
                <div class="control-inline">
                    <input placeholder="开始日期" class="form-control layer-date search_input" id="callStartTime" autocomplete="off"> -
                    <input placeholder="结束日期" class="form-control layer-date search_input" id="callEndTime" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label"><span class="respan">*</span>省份：</label>
                <div class="control-inline"  style="position: relative;">
                    <select type="text" id="pro" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">业务分类/场景：</label>
                <div class="control-inline">
                    <input type="text" id="workNameNew" value="" class="form-control search_input" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">满意度：</label>
                <div class="control-inline">
                    <select type="text" id="agree" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">重复来电：</label>
                <div class="control-inline">
                    <select type="text" id="repeatPhone" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">客户星级：</label>
                <div class="control-inline">
                    <select type="text" id="customerLevel"  class="form-control search_input selectpicker" title="请选择"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">话务小结：</label>
                <div class="control-inline">
                    <input type="text" id="tagTrafficSearch0" value="" class="form-control search_input tagName" autocomplete="off"  data-type="0">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">系统标签：</label>
                <div class="control-inline">
                    <input type="text" id="tagTrafficSearch1" value="" class="form-control search_input tagName" autocomplete="off" data-type="1">
                </div>
            </div>
            <div class="search_group">
                <button id="search" class="btn  btn-primary">查询</button>
                <button id="reset" class="btn  btn-default">重置</button>
                <button id="backUp" class="btn  btn-default" style="display: none;">返回省级地图</button>
            </div>
        </div>
        <div class="mapTitle" style="display: none">
            <span class="on" data-index="1">话务量排行</span>
            <span data-index="0">诉求量排行</span>
        </div>
        <div id="initTip" style="height:200px;line-height:200px;text-align:center;border: 1px solid #ddd;display: none">请选择必选条件哦！</div>
        <div class="chartsBox">
            <!--全国地图-->
            <div id="mapCharts" style="height:500px;" class="charts"></div>
            <!--省份地图-->
            <div id="subCharts" style="height:500px;" class="charts"></div>
        </div>
       <!--表格-->
        <div class="table_box" style="display: none">
            <div class="table_tools"><span class="downIcon" title="导出业务数据" id="export"></span></div>
            <table id="myTable"></table>
        </div>
    </div>
</div>
<!--导出-->
<form action="" id="exportForm" class="hidden" method="post">
    <input type="text" id="callStartTimeE" name="callStartTime">
    <input type="text" id="callEndTimeE" name="callEndTime">
    <input type="text" id="provinceE" name="province">
    <input type="text" id="provinceCodeE" name="provinceCode">
    <input type="text" id="customerLocE" name="customerLoc">
    <input type="text" id="cityNameE" name="cityName">
    <input type="text" id="classificationE" name="classification">
    <input type="text" id="sceneE" name="scene">
    <input type="text" id="satisfactionE" name="satisfaction">
    <input type="text" id="reCallFlagE" name="recallFlag">
    <input type="text" id="customerLevelE" name="customerLevel">
    <input type="text" id="sysTagIdsE" name="sysTagIds">
    <input type="text" id="sysOperatorE" name="sysOperator">
    <input type="text" id="telTagIdsE" name="telTagIds">
    <input type="text" id="telOperatorE" name="telOperator">
</form>
<form action="" id="formDetail" class="hidden" target="_blank">
    <input type="text" name="tagPro">
    <input type="text" name="tagProOnly">
    <input type="text" name="tagProName">
    <input type="text" name="tagProType">
    <input type="text" name="tagStartTime">
    <input type="text" name="tagEndTime">
    <input type="text" name="reCallFlag">
    <input type="text" name="satisfaction">
    <input type="text" name="customerLevels">
    <input type="text" name="tagSence">
    <input type="text" name="sysTagIds">
    <input type="text" name="sysTagNames">
    <input type="text" name="sysOperator">
    <input type="text" name="telTagIds">
    <input type="text" name="telTagNames">
    <input type="text" name="telOperator">
</form>
<input type="hidden" id="tagTreeId" value="" class="form-control search_input">
<input type="hidden" id="areaTreeId" value="" class="form-control search_input">
<input type="hidden" id="tagTreeType" value="" class="form-control search_input">
<input type="hidden" id="tagProperty" value="" class="form-control search_input">
<input type="hidden" id="workTreeId" value="" class="form-control search_input">
<input type="hidden" id="workAreaId" value="" class="form-control search_input">
<script src="../../../assert/js/jquery.js" th:src="@{/assert/js/jquery.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/echarts.min.js" th:src="@{/assert/js/echarts.min.js}"></script>
<script src="../../../assert/js/map/js/china.js" th:src="@{/assert/js/map/js/china.js}"></script>
<script src="../../../assert/js/bootstrap.min.js" th:src="@{/assert/js/bootstrap.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/bootstrap-table.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script src="../../../assert/js/bootstrap-select.js" th:src="@{/assert/js/bootstrap-select.js}"></script>
<script src="../../../assert/js/plugin/toastr/toastr.min.js"
        th:src="@{/assert/js/plugin/toastr/toastr.min.js}"></script>
<script src="../../../assert/js/base.js" th:src="@{/assert/js/base.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/jquery-ui.min.js" th:src="@{/assert/js/jquery-ui.min.js}"></script>
<script src="../../../assert/js/plugin/layer/laydate/laydate.js"
        th:src="@{/assert/js/plugin/layer/laydate/laydate.js}"></script>
<script src="../../../assert/js/changeTime.js" th:src="@{/assert/js/changeTime.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/jsTree/jstree.min.js"
        th:src="@{/assert/js/plugin/jsTree/jstree.min.js}"></script>
<script src="../../../assert/js/plugin/chosen/chosen.jquery.js"
        th:src="@{/assert/js/plugin/chosen/chosen.jquery.js}"></script>
<script src="../../../assert/js/contabs.min.js" th:src="@{/assert/js/contabs.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/common.js" th:src="@{/assert/js/common.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/city/city-picker.data.js" th:src="@{/assert/js/plugin/city/city-picker.data.js}"></script>
<script src="../../../assert/js/plugin/city/city-picker.js" th:src="@{/assert/js/plugin/city/city-picker.js}"></script>
<script src="../../../assert/js/taskCommon.js" th:src="@{/assert/js/taskCommon.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>

<script>
    //项目名称
    var basePath = $("#basePath").attr("href");;
    var json = [];
    //    表格初始化
    var TableInit = function () {
        var oTableInit = new Object();
        //初始化Table
        oTableInit.Init = function (json,name) {
            $('#myTable').bootstrapTable("destroy");
            $('#myTable').bootstrapTable({
                data:json,
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否显示分页（*）
                sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                sortable: true,                     //是否启用排序
                sortName: "callNum", //排序方式
                sortOrder: "desc",
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                columns: [
                    {
                        align: "center",
                        halign: "center",
                        title: '序号',//标题  可不加
                        width: 60,
                        formatter: function (value, row, index) {
                            return (index + 1) + "";
                        }
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'cityName',
                        title:'省份/市名',
                        formatter: function (value, row, index) {
                            return '<span>'+value+'</span>';
                        }
                    },
                    {
                        field: 'callNum',
                        title: '话务量',
                        align: "center",
                        halign: "center",
                        sortable: true,
                        formatter: function (value, row, index) {
                            return bs.jumpFormatter(value, JSON.stringify(row), parent.$('#isJumpBtn').length,'诉求量');
                        }
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'callPerc',
                        title: '话务量占比'
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'callHb',
                        title: '话务量环比'
                    },
                    {
                        field: 'appealNum',
                        title: '诉求量',
                        align: "center",
                        halign: "center",
                        sortable: true,
                        formatter: function (value, row, index) {
                            return bs.jumpFormatter(value, JSON.stringify(row), parent.$('#isJumpBtn').length,'诉求量');
                        }
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'appealPerc',
                        title: '诉求量占比'
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'appealHb',
                        title: '诉求量环比'
                    }
                ],
                onLoadSuccess: function (data) {  //加载成功时执行
                    if (!data.rows||data.rows.length == 0) {
                        var src=basePath+"/assert/image/nodata.png";
                        $(".no-records-found").find("td").html('<img src="'+src+'" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
                    var src=basePath+"/assert/image/nodata.png";
                    $(".no-records-found").find("td").html('<img src="'+src+'" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }
            });
        };
        //得到查询的参数
        oTableInit.queryParams = function (params) {
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                pageNum: params.offset,   //页面大小
                pageSize: params.limit,
                sortName: this.sortName,
                sortOrder: this.sortOrder,
                provinceCode: $("#pro").val(),
                groupId: $("#seatGroup").val(),
                seatNum: $("#seatId").val(),
                seatName: $("#seatName").val(),
                customerNum: $("#customerNumber").val(),
                callStartTime: $("#callStartTime").val(),
                callEndTime: $("#callEndTime").val(),
                recallFlag: $("#repeatPhone").val(),
            };
            return temp;
        };
        return oTableInit;
    };
    //    页面自适应
    var resize = {
        init: function () {
            resize.me();
            $(window).resize(function () {
                resize.me();
                if(subMap.myChart){
                    subMap.myChart.resize();
                }
                if(map.myChart){
                    map.myChart.resize();
                }
            })
        },
        me: function () {
            $('.charts').width($(window).width())
            var winW = $(window).width();
            var winH = $(window).height();
//            $(".ibox").width(winW - 20);
//            $(".ibox").height(winH - 20);
        }
    };
    //    查询条初始化
    var tools = {
        tableData: [],//表格数据
        reCallFlagArr: [],//重复来电
        agreeArr: [],//满意度
        proArr:[],//省市
        customerLevelArr:[],
        init: function () {
            tools.selectProvince();
            tools.getReCallFlag();
            tools.getSatStatus();
            tools.getCustomerLevel();
            bs.dataTime("#callStartTime","#callEndTime","YYYY-MM-DD");
            tools.tabSearch();
            tools.search();
            tools.reset();
            tools.refresh();
            tools.enterSearch();
            tools.export();
            tools.getNowTime();
            tools.tabTitle();
            tools.back();
            $("#pro").on("change",function(){
                var proCode=$("#pro").val();
                $("#workAreaId").val(proCode);
                $("#workNameNew").val('').attr('title','');
                menuWorkNew.init(proCode,'','1');//    获取业务数据
                tag.clearTag();
            });
            $("#myTable").on("click",".J_menuItem",function(){
                var row = JSON.parse($(this).attr('data-row'));
                var params = tools.jumpDetail(row);
                $(this).attr('href',basePath + "/rest/page/dataMiningAudioRetrieval?"+params);
            })
        },
        selectProvince: function () {
            tools.proArr = bs.getProvince('CHINA');
            tools.proArr[0].name="请选择";
            bs.selectDown($("#pro"), tools.proArr, "");
        },
        getCustomerLevel: function () {
            tools.customerLevelArr= bs.getStatus("audio_customer_level");
            bs.selectBootStrap($("#customerLevel"), tools.customerLevelArr);
        },
        getReCallFlag:function(){
            var dataArr = bs.getStatus("recall_flag");
            Object.assign(tools.reCallFlagArr,dataArr);//es6复制数组的方法
            tools.reCallFlagArr[0].name="请选择";
            bs.selectDown($("#repeatPhone"), tools.reCallFlagArr);
        },
        getSatStatus:function(){
            var dataArr = bs.getStatus("audio_satisfaction");
            Object.assign(tools.agreeArr,dataArr);//es6复制数组的方法
            tools.agreeArr[0].name="请选择";
            bs.selectDown($("#agree"), tools.agreeArr);
        },

        changeState: function (value, arr) {
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                if (value == arr[i].value) {
                    str = arr[i].name
                }
            }
            return str;
        },
        tabSearch: function () {
            var search = $(".search");
            $("#btnSearch").on("click", function () {
                if (search.hasClass("on")) {
                    search.slideUp();
                    search.removeClass("on");
                    $("#btnSearch").html('<i class="fa fa-filter"></i> 查询').attr("title", "显示查询条");
                } else {
                    search.slideDown();
                    search.addClass("on");
                    $("#btnSearch").html('<i class="fa fa-filter"></i> 隐藏').attr("title", "隐藏查询条");
                }

            });
        },
        search: function () {
            $("#search").on("click", function () {
                if($("#callStartTime").val()=="" || $("#callEndTime").val()==""){
                    toastrCog.error("请选择日期！",2000);
                    return
                }
                if($("#pro").val()==""){
                    toastrCog.error("请选择省份！",2000);
                    return
                }
                var index=$(".mapTitle span.on").attr('data-index');
                getData.isLoadData(index);
            })
        },
        reset: function () {
            $("#reset").on("click", function () {
                bs.resetSearch($(".search"));
                if($("#laydate_box").length>0){
                    bs.resetTimeElems("#callStartTime","#callEndTime");
                }
                var proCode = $("#spanId", parent.document).attr("data-procode");
                if(proCode == ''){
                    $("#workAreaId").val(proCode);
                    menuWorkNew.init(proCode,$('#jstree'),'1');//    获取业务数据
                    $("#workNameNew").val('').attr('title','');
                }
                tag.clearTag();
                getData.isLoadData(1);
            })
        },
        resetSelect: function ($obj) {
            $obj.val("");
            $obj.trigger("chosen:updated");
        },
        refresh: function () {
            $("#refresh").on("click", function () {
                $("#search").click();
            })
        },
        tableRefresh: function () {
            $("#myTable").bootstrapTable('refresh');
        },
        enterSearch: function () {
            $(".search").not("#searchInput").on("keyup", function (e) {
                var code = e.charCode || e.keyCode;
                if (code == 13) {
                    //此处编写用户敲回车后的代码
                    $("#search").click();
                }
            })
        },
        export: function () {
            $("#export").on("click", function () {
                if (getData.dataAll.length==0) {
                    toastrCog.error("没有可导出的数据哦！",2000)
                    return;
                }
                var form = $("#exportForm");
                var proCode=$("#pro").val();
                var pro=bs.getXInY(tools.proArr,"name","value",proCode);
                $("#callStartTimeE").val($("#callStartTime").val());
                $("#callEndTimeE").val($("#callEndTime").val());
                $("#provinceE").val(pro);
                $("#provinceCodeE").val(proCode);
                $("#classificationE").val($("#workNameNew").val());
                $("#sceneE").val($("#workNameNew").val());
                $("#satisfactionE").val($("#agree").val());
                $("#reCallFlagE").val($("#repeatPhone").val());
                $("#customerLevelE").val($("#customerLevel").val());
                $("#sysTagIdsE").val($("#tagTrafficSearch1").val());
                $("#sysOperatorE").val($("#tagTrafficSearch1").attr("data-relation"));
                $("#telTagIdsE").val($("#tagTrafficSearch0").val());
                $("#telOperatorE").val($("#tagTrafficSearch0").attr("data-relation"));
                window.open( bs.getSysConfig("SJWJ_URL_PRE").value+'/exportExcel/areaExport?'+form.serialize())
            })

        },
        getNowTime:function(){
            var endTime=dateFormatUtil(new Date().getTime()).split(" ")[0];
            var str=endTime.split(" ")[0];
            var startTime=str.substr(0,str.length-2)+"01";
            $("#callStartTime").val(startTime);
            $("#callEndTime").val(endTime);
            bs.allTimeElem["#callEndTime"].min = startTime;
            bs.allTimeElem["#callEndTime"].start =  startTime;
            bs.allTimeElem["#callStartTime"].max =  endTime;
        },
        back:function(){
            $("#backUp").on("click",function(){
                $("#mapCharts").show();
                $("#subCharts").hide();
                $("#backUp").hide();
            });
        },
        tabTitle:function(){
            $(".mapTitle span").on("click",function(){
                $(this).addClass("on").siblings().removeClass("on");
                $("#search").click();
            })
        },
        jumpDetail:function(row){
            var form=$("#formDetail");
            var proCode = $("#pro").val();
            var city = row.customerLoc;
            var cityName = row.cityName;
            var callStartTimeC = $("#callStartTime").val();
            var callEndTimeC = $("#callEndTime").val();
            var reCallFlagC = $("#repeatPhone").val();
            var satisfactionC = $("#agree").val();
            var customerLevelsC = $("#customerLevel").val();
            var telElem = $('#tagTrafficSearch0');
            var sysElem = $('#tagTrafficSearch1');
            if(proCode == 'CHINA'){
                proCode = row.customerLoc;
                city = '';
            }
            if(proCode == 'BJ'){
                cityName = '北京';
                city = '';
            }
            if(proCode == 'TJ'){
                cityName = '天津';
                city = '';
            }
            var proObj = JSON.stringify(proCity.formatter(proCode,[city]));
            var proName = proCity.formatterName('',cityName);
            form.find("input[name='tagPro']").val(proObj);
            if($("#pro").val() != 'CHINA'){//如果选择了具体市 省份为空
                form.find("input[name='tagProOnly']").val('{}');
            }else{//如果选择了具体省份
                form.find("input[name='tagProOnly']").val(proObj);
            }
            form.find("input[name='tagProName']").val(proName);
            form.find("input[name='tagProType']").val('0');
            form.find("input[name='tagStartTime']").val(callStartTimeC);
            form.find("input[name='tagEndTime']").val(callEndTimeC);
            form.find("input[name='reCallFlag']").val(reCallFlagC);
            form.find("input[name='satisfaction']").val(satisfactionC);
            form.find("input[name='customerLevels']").val(customerLevelsC);
            form.find("input[name='tagSence']").val($('#workNameNew').val());
            form.find("input[name='telTagIds']").val(telElem.attr('data-id'));
            form.find("input[name='telTagNames']").val(telElem.val());
            form.find("input[name='telOperator']").val(telElem.attr('data-relation'));
            form.find("input[name='sysTagIds']").val(sysElem.attr('data-id'));
            form.find("input[name='sysTagNames']").val(sysElem.val());
            form.find("input[name='sysOperator']").val(sysElem.attr('data-relation'));
            return form.serialize();
        }

    };
    //    全国地图
    var map = {
        randomData:function(){
            return Math.round(Math.random()*500);
        },
        mydata:null,
        chart: null,
        data: null,
        dataList: null,
        valueList: null,
        firstInit: function () {
            map.myChart = echarts.init(document.getElementById('mapCharts'));
        },
        init:function(name,subArr,splitArr){
            map.option={
                backgroundColor: '#FFFFFF',
                title: {
                    text: '全国地图数据',
                    subtext: '',
                    x:'center'
                },
                tooltip : {
                    trigger: 'item',
                    formatter: function (params) {
                        var index=$(".mapTitle span.on").attr('data-index');
                        var typeName="";
                        if(index==0){
                            typeName="诉求量"
                        }else{
                            typeName="话务量"
                        }
                        var name='',data='',hb='',zb='';
                        if(params.data){
                            name = params.data.name;
                            data = params.data.value;
                            hb = params.data.hb;
                            zb = params.data.zb;
                        }
                        var str=name+"<br><span class='dot c1'></span>"+typeName+":"+data+"<br>";
                        if(zb){
                            str+="<span class='dot c3'></span>"+typeName+"占比:"+zb+"<br>";
                        }
                        if(hb){
                            str+="<span class='dot c4'></span>"+typeName+"环比:"+hb;
                        }
                        return str;
                    }
                },
                toolbox: {
                    feature: {
                        saveAsImage: {}
                    }
                },
                //左侧小导航图标
                visualMap: {
                    show : true,
                    x: 'left',
                    y: 'center',
                    splitList: splitArr,
                    color: ['#054e8d', '#196bb2', '#3f82bc','#6396c2', '#88a8c4', '#c5d2dd']
                },

                //配置属性
                series: [{
                    name: '数据',
                    type: 'map',
                    mapType: 'china',
                    roam: true,
                    label: {
                        normal: {
                            show: true  //省份名称
                        },
                        emphasis: {
                            show: false
                        }
                    },
                    data:[]  //数据
                }]
            };
            map.myChart.setOption(map.option);
            map.renderOption(subArr);
        },
        renderOption:function(subArr){
            map.mydata=subArr;
            map.option.series[0].data= map.mydata;
            if(!bs.isNumber(getData.max)){
                map.option.visualMap.show=false;
            }
            //  导出图片的名字
            var codeType=$(".mapTitle span.on").attr('data-index');
            if(codeType==0){
                map.option.toolbox.feature.saveAsImage.name="地区热力图诉求量";
            }else{
                map.option.toolbox.feature.saveAsImage.name="地区热力图话务量";
            }
            map.myChart.setOption(map.option);

            // map.option.series[0].data= map.mydata;
            // map.myChart.setOption(map.option);
            // map.myChart.on('click', function (params) {
            //     // $("#mapCharts").hide();
            //     // $("#subCharts").show();
            //     // $("#backUp").show();
            //     var name=params.name;
            //     var code=params.data.code;
            //     $.get('../../assert/js/map/json/province/'+code+'.json', function (Citymap) {
            //         var subArr=[];
            //         var arr=Citymap.features;
            //         for(var i=0;i<arr.length;i++){
            //            var obj={};
            //            var name1= arr[i].properties.name;
            //             obj.name=name1;
            //             obj.value= map.randomData();
            //             subArr.push(obj);
            //         }
            //         echarts.registerMap(name, Citymap);
            //         subMap.init(name,subArr);
            //     })
            // });
        }
    };
    //    省份地图
    var subMap={
        mydata:null,
        chart: null,
        data: null,
        dataList: null,
        valueList: null,
        firstInit:function(){
            subMap.myChart = echarts.init(document.getElementById('subCharts'));
        },
        init: function (name,subArr,splitArr) {
            subMap.option={
                backgroundColor: '#FFFFFF',
                title: {
                    text: name+'地图数据',
                    subtext: '',
                    x:'center'
                },
                tooltip : {
                    trigger: 'item',
                    formatter: function (params) {
                        var index=$(".mapTitle span.on").attr('data-index');
                        var typeName="";
                        if(index==0){
                            typeName="诉求量"
                        }else{
                            typeName="话务量"
                        }
                        var name = params.data.name;
                        var data = params.data.value;
                        var hb = params.data.hb;
                        var zb = params.data.zb;
                        var str=name+"<br><span class='dot c1'></span>"+typeName+":"+data+"<br>";
                        if(zb){
                            str+="<span class='dot c3'></span>"+typeName+"占比:"+zb+"<br>";
                        }
                        if(hb){
                            str+="<span class='dot c4'></span>"+typeName+"环比:"+hb;
                        }
                        return str;
                    }
                },
                toolbox: {
                    feature: {
                        saveAsImage: {}
                    }
                },
                //左侧小导航图标
                visualMap: {
                    show : true,
                    x: 'left',
                    y: 'center',
                    splitList: splitArr,
                    color: ['#054e8d', '#196bb2', '#3f82bc','#6396c2', '#88a8c4', '#c5d2dd']
                },

                //配置属性
                series: [{
                    name: '数据',
                    type: 'map',
                    mapType: name,
                    roam: true,
                    label: {
                        normal: {
                            show: true  //省份名称
                        },
                        emphasis: {
                            show: false
                        }
                    },
                    data:[]  //数据
                }]
            };
            subMap.myChart.setOption(subMap.option);
            subMap.renderOption(subArr);
        },
        renderOption:function(subArr){
            subMap.mydata=subArr;
            subMap.option.series[0].data= subMap.mydata;
            if(!bs.isNumber(getData.max)){
                subMap.option.visualMap.show=false;
            }
            //  导出图片的名字
            var codeType=$(".mapTitle span.on").attr('data-index');
            if(codeType==0){
                subMap.option.toolbox.feature.saveAsImage.name="地区热力图诉求量";
            }else{
                subMap.option.toolbox.feature.saveAsImage.name="地区热力图话务量";
            }
            subMap.myChart.setOption(subMap.option);
        }
    };
    //    获取数据
    var getData={
        init:function(codeType){
            map.myChart.showLoading();
            subMap.myChart.showLoading();
            var proCode=$("#pro").val();
            var pro=bs.getXInY(tools.proArr,"name","value",proCode);
            var pinyin=bs.getXInY(tools.proArr,"pinyin","value",proCode);
            var params={
                callStartTime:$("#callStartTime").val(),//语音开始的日期
                callEndTime:$("#callEndTime").val(),//语音结束的日期
                province:pro,//省份
                provinceCode:proCode,//省份的编码
                scene:$("#workNameNew").val(),//具体的业务场景
                classification:$("#workNameNew").val(),//业务的分类id
                satisfaction:$("#agree").val(),//该通通话客户之满意度
                recallFlag:$("#repeatPhone").val(),//该通通话是否是重复来电
                customerLevel: $("#customerLevel").val(),
                sysTagIds: $("#tagTrafficSearch1").val(),
                sysOperator: $("#tagTrafficSearch1").attr('data-relation'),
                telTagIds: $("#tagTrafficSearch0").val(),
                telOperator: $("#tagTrafficSearch0").attr('data-relation')
            };
            $.ajax({
                type: "POST",
                url: bs.getSysConfig("SJWJ_URL_PRE").value+'/dataMining/areaAnalysis',
                dataType: "json",
                contentType: 'application/json',
                data:JSON.stringify(params),
                success: function (data) {
                    var code=data.rtnCode;
                    if (code ==0) {
                        var result=data.data;
                        var oTable = new TableInit();
                        oTable.Init(result,pro);
                        map.myChart.clear();
                        subMap.myChart.clear();
                        map.myChart.hideLoading();
                        subMap.myChart.hideLoading();
                        getData.dataAll=result;
                        //生成统计图左侧数据范围段
                        var callArr=[];
                        for(var j=0;j< result.length;j++){
                            if(result[j].cityName!="全省"){
                                if(codeType==0){
                                    callArr.push(result[j].appealNum);
                                }else{
                                    callArr.push(result[j].callNum);
                                }
                            }
                        }
                        getData.max=Math.max.apply(null,callArr);
                        var space=Math.floor(getData.max/6)+"";
                        var sLen=space.length;
                        var firstStr=space.substr(0,1);
                        firstStr=parseInt(firstStr)+1;
                        for(var i=0;i<sLen-1;i++){
                            firstStr+="0";
                        }
                        var splitArr=[];
                        var num=0;
                        for(var i=0;i<6;i++){
                            var obj={};
                            obj.start=num;
                            num+=parseInt(firstStr);
                            obj.end=num;
                            splitArr.push(obj);
                        }
                        if(proCode!="SJBZ" && proCode!="" && proCode!="CHINA"){
                            getData.getProData(pinyin,pro,splitArr,codeType);
                        }
                        if(proCode=="CHINA"){
                            getData.getChinaData(pinyin,pro,splitArr,codeType);
                        }
                    }else{
                        toastrCog.error(data.rtnMsg);
                    }
                }
            });
        },
        getProData:function(code,name,splitArr,codeType){
            $.get('../../assert/js/map/json/province/'+code+'.json', function (Citymap) {
                var data=getData.dataAll;
                var subArr=[];
                var arr=Citymap.features;
                for(var i=0;i<arr.length;i++){
                    var obj={};
                    var name1= arr[i].properties.name;
                    obj.name=name1;
                    obj.value= 0;
                    obj.zb= '0%';
                    obj.hb= 0;
                    for(var j=0;j< data.length;j++){
                        var cityName=data[j].cityName;
                        var callNum=data[j].callNum;
                        var appealNum=data[j].appealNum;
                        var callHb=data[j].callHb;
                        var appealPerc=data[j].appealPerc;
                        var callPerc=data[j].callPerc;
                        var appealHb=data[j].appealHb;
                        if(cityName!=""){
                            if(name1.indexOf(cityName)>-1){
                                if(codeType==0){
                                    obj.value=appealNum;
                                    obj.zb=appealPerc;
                                    obj.hb=appealHb;
                                }else{
                                    obj.value=callNum;
                                    obj.zb=callPerc;
                                    obj.hb=callHb;
                                }
                                break;
                            }
                        }

                    }
                    subArr.push(obj);
                }
                echarts.registerMap(name, Citymap);
                subMap.init(name,subArr,splitArr);
                map.init(name,subArr,splitArr);
            })
        },
        getChinaData:function(code,name,splitArr,codeType){
            var data=getData.dataAll;
            var subArr=[];
            var arr= [
                {name: '北京',value: '',code:"beijing" },
                {name: '天津',value: '',code:"天津" },
                {name: '上海',value: '',code:"shanghai" },
                {name: '重庆',value: '',code:"chongqing" },
                {name: '河北',value: '',code:"hebei" },
                {name: '河南',value: '',code:"henan" },
                {name: '云南',value: '',code:"yunnan" },
                {name: '辽宁',value: '',code:"liaoning" },
                {name: '黑龙江',value: '',code:"heilongjiang" },
                {name: '湖南',value: '',code:"hunan" },
                {name: '安徽',value: '',code:"anhui" },
                {name: '山东',value: '',code:"shandong" },
                {name: '新疆',value: '',code:"xinjiang" },
                {name: '江苏',value: '',code:"jiangsu" },
                {name: '浙江',value: '',code:"zhejiang" },
                {name: '江西',value: '',code:"jiangxi" },
                {name: '湖北',value: '',code:"hubei" },
                {name: '广西',value: '',code:"guangxi" },
                {name: '甘肃',value: '',code:"gansu"},
                {name: '山西',value: '',code:"shanxi" },
                {name: '内蒙古',value: '',code:"neimenggu" },
                {name: '陕西',value: '',code:"shanxi" },
                {name: '吉林',value: '',code:"jilin" },
                {name: '福建',value: '',code:"fujian" },
                {name: '贵州',value: '',code:"guizhou" },
                {name: '广东',value: '',code:"guangdong" },
                {name: '青海',value: '',code:"qinghai" },
                {name: '西藏',value: '',code:"xizang" },
                {name: '四川',value: '',code:"sichuan" },
                {name: '宁夏',value: '',code:"ningxia" },
                {name: '海南',value: '',code:"hainan" },
                {name: '台湾',value: '',code:"taiwan" },
                {name: '香港',value: '' ,code:"xianggang"},
                {name: '澳门',value: '',code:"aomen" }
            ];
            for(var i=0;i<arr.length;i++){
                var obj={};
                var name1= arr[i].name;
                var code= arr[i].code;
                obj.name=name1;
                obj.code=code;
                obj.value= 0;
                // obj.zb= '0%';
                // obj.hb= 0;
                for(var j=0;j< data.length;j++){
                    var cityName=data[j].cityName;
                    var callNum=data[j].callNum;
                    var appealNum=data[j].appealNum;
                    var callHb=data[j].callHb;
                    var appealPerc=data[j].appealPerc;
                    var callPerc=data[j].callPerc;
                    var appealHb=data[j].appealHb;
                    if(cityName!=""){
                        if(name1.indexOf(cityName)>-1){
                            if(codeType==0){
                                obj.value=appealNum;
                                // obj.zb=appealPerc;
                                // obj.hb=appealHb;
                            }else{
                                obj.value=callNum;
                                // obj.zb=callPerc;
                                // obj.hb=callHb;
                            }
                            break;
                        }
                    }

                }
                subArr.push(obj);
            }
            map.init(name,subArr,splitArr);
        },
        isLoadData:function(codeType){
            if($("#callStartTime").val()!="" && $("#pro").val()!=""){
                $("#subCharts").show();
                $("#mapCharts").show();
                if($("#pro").val()=="SJBZ" || $("#pro").val()=="CHINA"){
                    $("#mapCharts").show();
                    $("#subCharts").hide();
                }else{
                    $("#subCharts").show();
                    $("#mapCharts").hide();
                }
                $(".table_box").show();
                $(".mapTitle").show();
                $("#initTip").hide();
                getData.init(codeType);//    获取数据
            }else{
                $("#subCharts").hide();
                $("#mapCharts").hide();
                $(".table_box").hide();
                $(".mapTitle").hide();
                $("#initTip").show();
            }
        }
    };
    $(function () {
        tools.init();//    查询条初始化
        map.firstInit();//    全国地图初始化
        subMap.firstInit();//    省份地图初始化
        var oTable = new TableInit();//    表格初始化
        oTable.Init([]);
        resize.init();//    页面自适应
        getData.isLoadData(0);
        var proCode=$("#pro").val();
        $("#workAreaId").val(proCode);
        menuWorkNew.init(proCode,$('#jstree'),'1');//    获取业务数据
        workNew.init(proCode,$('#jstree'));
        tag.init($("#pro"),'Search','0');
    })
</script>
</body>
</html>